<?php

	include("php/db.php");

	$conn = new Conexao();
	$conn->open();

	$id = $_POST["id"];
	$action = $_POST["action"];
	$type = $_POST['type'];

	if ($action == 'show' && $type == 'local' ) {

		$querystring = '
		SELECT 
		pt.id, pt.justification, pt.place_name, pt.place_category, pt.place_address, pt.place_description,
		places.name as pname, places.category as pcategory, places.address as paddress, places.description as pdesc
		FROM places_tickets as pt
		INNER JOIN places
		ON pt.place_id = places.id
		WHERE pt.id ='.$id;

		$query = pg_query($querystring);

		$arr = pg_fetch_array($query,0);

		echo json_encode($arr);

	}

	if ($action == 'recuse') {
		$querystring = 'DELETE from places_tickets WHERE id='.$id;
		$query = pg_query($querystring);

		echo 'sucesso';
	}


	$conn->close();
?>
